home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / initShelf.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  11.3 KB  |  396 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  Aug 15 1996
  22. //  Author:         llm
  23. //
  24. //  Description:
  25. //      This script initializes the Shelf.  Initialization involves
  26. //        determining the initial Shelf preferences, creating the UI and
  27. //        setting the initial visibility.
  28. //
  29. {
  30.     //  Check Shelf tab preferences.
  31.     //
  32.     int    $i, $nShelves;
  33.     int    $usePrefs = false;
  34.     int    $isFirstTime = false;
  35.     string $name, $proc;
  36.     string $shelfDir, $sysReturn, $tmp;
  37.     string $unsortedFiles[];
  38.     string $files[];
  39.     string $names[];
  40.     
  41.     //
  42.     //      get a list of files in the shelves directory
  43.     //
  44.     $shelfDir = `internalVar -userShelfDir`;
  45.     $unsortedFiles = `getFileList -folder $shelfDir -fs "shelf_*.mel"`;
  46.     //
  47.     // sort this list
  48.     //
  49.     $files = sort ($unsortedFiles);
  50.     $nShelves = size($files);
  51.  
  52.     if (0 == $nShelves) {
  53.  
  54.         $isFirstTime = true;
  55.  
  56.         //  
  57.         //  No existing shelves, so use the default shelf setup.
  58.         //
  59.         if (`about -windows` || `about -mac`) {
  60.             //
  61.             //    Create a new set of default shelves for Windows
  62.             //    only.
  63.             //
  64.  
  65.             //    The following table defines the order of shelves 
  66.             //    available for each version of Maya.
  67.             //
  68.             //    All Versions    Complete        Unlimited
  69.             //    --------------------------------------------
  70.             //    General         General         General
  71.             //    Curves          Curves          Curves
  72.             //    Surfaces        Surfaces        Surfaces
  73.             //    Polygons        Polygons        Polygons
  74.             //                    Subdivs         Subdivs
  75.             //    Deformation     Deformation     Deformation
  76.             //    Animation       Animation       Animation
  77.             //                    Dynamics        Dynamics
  78.             //    Rendering       Rendering       Rendering
  79.             //                    PaintEffects    PaintEffects
  80.             //                                    Cloth
  81.             //                                    Fluids
  82.             //                                    Fur
  83.             //
  84.             //    From the table above you will count that there
  85.             //    are:
  86.             //    
  87.             //    7 Shelves for all versions
  88.             //    10 Complete shelves
  89.             //    13 Unlimited shelves
  90.  
  91.             //    The General, Curves, Surfaces, and Polygons shelves
  92.             //    are all available for all versions of Maya.
  93.             //
  94.             //    Note that each shelf may have individual items available 
  95.             //    only in certain versions. See each shelf script for these
  96.             //    items.
  97.             //
  98.             optionVar 
  99.                 -stringValue  shelfName1      "General"
  100.                 -stringValue  shelfFile1      "shelf_General" 
  101.                 -intValue     shelfLoad1      true
  102.  
  103.                 -stringValue  shelfName2      "Curves"
  104.                 -stringValue  shelfFile2      "shelf_Curves" 
  105.                 -intValue     shelfLoad2      true
  106.  
  107.                 -stringValue  shelfName3      "Surfaces"
  108.                 -stringValue  shelfFile3      "shelf_Surfaces" 
  109.                 -intValue     shelfLoad3      true
  110.  
  111.                 -stringValue  shelfName4      "Polygons"
  112.                 -stringValue  shelfFile4      "shelf_Polygons" 
  113.                 -intValue     shelfLoad4      true
  114.                 ;
  115.  
  116.             if (`licenseCheck -type complete`) {
  117.                 //
  118.                 //    --- Complete ---
  119.                 //
  120.                 //    Create the Subdivs, Deformation, Animation, Dynamics,
  121.                 //    and Rendering shelves.
  122.                 //
  123.                 optionVar
  124.                     -stringValue  shelfName5      "Subdivs"
  125.                     -stringValue  shelfFile5      "shelf_Subdivs" 
  126.                     -intValue     shelfLoad5      true
  127.  
  128.                     -stringValue  shelfName6      "Deformation"
  129.                     -stringValue  shelfFile6      "shelf_Deformation" 
  130.                     -intValue     shelfLoad6      true
  131.  
  132.                     -stringValue  shelfName7      "Animation"
  133.                     -stringValue  shelfFile7      "shelf_Animation" 
  134.                     -intValue     shelfLoad7      true
  135.  
  136.                     -stringValue  shelfName8      "Dynamics"
  137.                     -stringValue  shelfFile8      "shelf_Dynamics" 
  138.                     -intValue     shelfLoad8      true
  139.  
  140.                     -stringValue  shelfName9      "Rendering"
  141.                     -stringValue  shelfFile9      "shelf_Rendering" 
  142.                     -intValue     shelfLoad9      true
  143.  
  144.                     -stringValue  shelfName10      "PaintEffects"
  145.                     -stringValue  shelfFile10      "shelf_PaintEffects" 
  146.                     -intValue     shelfLoad10      true
  147.                     ;
  148.  
  149.                 if( fluidEditLicenseFound() ) {
  150.                     //
  151.                     //    --- Unlimited ---
  152.                     //
  153.                     //    Add the Cloth, Fur and Fluids shelves.
  154.                     //
  155.                     optionVar
  156.                         -stringValue  shelfName11     "Cloth"
  157.                         -stringValue  shelfFile11     "shelf_Cloth" 
  158.                         -intValue     shelfLoad11     true
  159.  
  160.                         -stringValue  shelfName12     "Fluids"
  161.                         -stringValue  shelfFile12     "shelf_Fluids" 
  162.                         -intValue     shelfLoad12     true
  163.  
  164.                         -stringValue  shelfName13     "Fur"
  165.                         -stringValue  shelfFile13     "shelf_Fur" 
  166.                         -intValue     shelfLoad13     true
  167.  
  168.                         //    Add empty shelf.
  169.                         //
  170.                         -stringValue  shelfName14     "Custom"
  171.                         -stringValue  shelfFile14     "shelf_Shelf1" 
  172.                         -intValue     shelfLoad14     true
  173.                         ;
  174.  
  175.                     $nShelves = 14;
  176.  
  177.                 } else {
  178.                     //
  179.                     //    --- Complete ---
  180.                     //
  181.                     //    Add empty shelf.
  182.                     //
  183.                     optionVar
  184.                         -stringValue  shelfName11     "Custom"
  185.                         -stringValue  shelfFile11     "shelf_Shelf1" 
  186.                         -intValue     shelfLoad11     true
  187.                         ;
  188.  
  189.                     $nShelves = 11;
  190.                 }
  191.  
  192.             } else {
  193.                 //
  194.                 //    --- All Versions ---
  195.                 //
  196.                 //    Create the Deformation, Animation, and Rendering
  197.                 //    shelves.
  198.                 //
  199.                 optionVar
  200.                     -stringValue  shelfName5      "Deformation"
  201.                     -stringValue  shelfFile5      "shelf_Deformation" 
  202.                     -intValue     shelfLoad5      true
  203.  
  204.                     -stringValue  shelfName6      "Animation"
  205.                     -stringValue  shelfFile6      "shelf_Animation" 
  206.                     -intValue     shelfLoad6      true
  207.  
  208.                     -stringValue  shelfName7      "Rendering"
  209.                     -stringValue  shelfFile7      "shelf_Rendering" 
  210.                     -intValue     shelfLoad7      true
  211.  
  212.                     -stringValue  shelfName8      "Custom"
  213.                     -stringValue  shelfFile8      "shelf_Shelf1" 
  214.                     -intValue     shelfLoad8      true
  215.                     ;
  216.  
  217.                 $nShelves = 8;
  218.             }
  219.  
  220.             optionVar 
  221.                 -stringValue  shelfItemSize   "Small" 
  222.                 -stringValue  shelfItemStyle  "iconOnly"
  223.  
  224.                 -intValue     isShelfVisible  true
  225.                 -intValue     isShelfLoad     true
  226.                 -intValue     numShelves      $nShelves;
  227.  
  228.         } else {
  229.             //
  230.             //    For Irix and Linux, stick with the old default
  231.             //    shelves.
  232.             //
  233.             $nShelves = 2;
  234.             optionVar 
  235.                 -stringValue  shelfName1      "Shelf1"
  236.                 -stringValue  shelfFile1      "shelf_Common" 
  237.                 -intValue     shelfLoad1      true
  238.  
  239.                 -stringValue  shelfName2      "Shelf2"
  240.                 -stringValue  shelfFile2      "shelf_Shelf2" 
  241.                 -intValue     shelfLoad2      true
  242.  
  243.                 -stringValue  shelfItemSize   "Small" 
  244.                 -stringValue  shelfItemStyle  "iconOnly"
  245.  
  246.                 -intValue     isShelfVisible  true
  247.                 -intValue     isShelfLoad     true
  248.                 -intValue     numShelves      $nShelves;
  249.         }
  250.  
  251.     } else {
  252.         //
  253.         //  Compare existing prefs with what's in the directory.
  254.         //    It is preferable to use prefs as they contain order info also.
  255.         //
  256.         int $nArr = `optionVar -q numShelves`;
  257.         string $prefFiles[];
  258.         string $sortedPrefFiles[];
  259.  
  260.         //  build array of files from prefs and sort it
  261.         //
  262.         for ($i = 0; $i < $nShelves; $i++) {
  263.             $prefFiles[$i] = (`optionVar -q ("shelfFile"+($i+1))` + ".mel");
  264.         }
  265.         $sortedPrefFiles = sort ($prefFiles);
  266.             
  267.         //  compare with the file in the directory.
  268.         //     - if there is any discrpency then don't trust the prefs.
  269.         //
  270.         if (size($sortedPrefFiles) == $nShelves) {
  271.             $usePrefs = true;
  272.             for ($i = 0; $i < $nShelves; $i++) {
  273.                 if ($sortedPrefFiles[$i] != $files[$i]) {
  274.                     $usePrefs = false;
  275.                     break;
  276.                 }
  277.             }
  278.         }
  279.  
  280.         if (!$usePrefs) {
  281.             //
  282.             //  Create shelves from directory
  283.             // The double backslash is to prevent the '.' from being
  284.             // used as a wildcard.
  285.             //
  286.             for ($i = 1; $i <= $nShelves; $i++) {
  287.                 $tmp = $files[$i-1];
  288.                 $proc = `substitute "\\.mel" $tmp ""`;
  289.                 $name = `substitute "shelf_" $proc ""`;
  290.  
  291.                 optionVar 
  292.                     -stringValue ("shelfName"+$i) $name
  293.                     -stringValue ("shelfFile"+$i) $proc
  294.                     -intValue ("shelfLoad"+$i) true;
  295.             }
  296.  
  297.             optionVar -intValue numShelves $nShelves;
  298.         }
  299.     }
  300.     
  301.     //  Create the Shelf.
  302.     // 
  303.     if (`exists shelf`) {
  304.         eval "source shelf";
  305.     }
  306.  
  307.     //    Attach a callback so we know when the Shelf is made visible or 
  308.     //    invisible.
  309.     //
  310.     setUIComponentStateCallback("Shelf", "shelfVisibilityStateChange");
  311.  
  312.     //    Set the Shelf's initial visibility.
  313.     //
  314.     setShelfVisible(`optionVar -q isShelfVisible`);
  315.  
  316.     //    If this is the first time shelves are loaded then we must rename
  317.     //    the option var for the Custom shelf (Windows) and the Common
  318.     //    shelf (other platforms) to match the corresponding shelf labels.
  319.     //
  320.     //    If the file and label don't match then the shelves won't load 
  321.     //    from preferences and retain the user's order (they'll
  322.     //    come back in alphabetical order).
  323.     //
  324.     if ($isFirstTime) {
  325.         if (`about -windows` || `about -mac`) {
  326.             optionVar -stringValue ("shelfFile" + $nShelves) "shelf_Custom";
  327.         } else {
  328.             optionVar -stringValue shelfFile1 "shelf_Shelf1";
  329.         }
  330.     }
  331.  
  332.     // Fix shelf items that have obsolete or incorrect commands
  333.     // associated with them.  Once the shelves have been fixed,
  334.     // turn on a variable so that they are not processed again
  335.     // in this version.
  336.     string $nowVer = `about -v`;
  337.     string $lastVer = "";
  338.     if( `optionVar -exists shelvesLastUpdated` ) {
  339.         $lastVer = `optionVar -q shelvesLastUpdated`;
  340.     }
  341.  
  342.     if( $nowVer != $lastVer ) {
  343.         optionVar -sv shelvesLastUpdated $nowVer;
  344.         source updateShelves.mel;
  345.     }
  346. }
  347.  
  348. global proc int shelfVisibilityStateChange(
  349.     int    $newState,
  350.     string $layout)
  351. //
  352. //    Description:
  353. //        This procedure is called whenever the visibility state of the 
  354. //        Shelf is changed.
  355. //
  356. //        Create the contents of the Shelf when it is shown for the first 
  357. //        time.
  358. //
  359. //    Arguments:
  360. //        newState - The new visibile state of the Shelf.
  361. //
  362. //        layout - The parent layout for the Shelf.
  363. //
  364. //    Returns:
  365. //        true - If the change of state is to be allowed.
  366. //
  367. //        false - If the state change is rejected.
  368. //
  369. {
  370.     global int    $gShelfCreated = false;
  371.  
  372.     int    $result = true;
  373.  
  374.     if ($newState) {
  375.  
  376.         //    Load the contents of the Shelf right before it becomes visible
  377.         //    for the very first time.
  378.         //
  379.         if (!$gShelfCreated) {
  380.             buildShelves();
  381.             $gShelfCreated = true;
  382.         }
  383.  
  384.     } else {
  385.     }
  386.  
  387.     //    Defer these commands because this proc is called when the visibility
  388.     //    state is about to change. This proc must return true to accept 
  389.     //    the state change. After this proc returns then restore the
  390.     //    panel focus and update the pref menu.
  391.     //
  392.     evalDeferred("restoreLastPanelWithFocus(); updatePrefsMenu();");
  393.  
  394.     return $result;
  395. }
  396.